#include<iostream>
#include<vector>
using namespace std;
struct TreeNode 
{
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
	TreeNode(int x) :
		val(x), left(NULL), right(NULL) 
	{}
};
class Solution {
public:
	void _FindPath(TreeNode* root, int expectNumber, vector<int>& nums, vector<vector<int>>& retnums)
	{
		expectNumber -= root->val;
		if ((root == nullptr && expectNumber != 0) || expectNumber < 0 || (expectNumber == 0 && root))
			return;
		if(expectNumber != 0 && root)
			nums.push_back(root->val);
		else if (expectNumber == 0 && !root)
		{
			retnums.push_back(nums);
			nums.clear();
			return;
		}
		_FindPath(root->left, expectNumber, nums, retnums);
		_FindPath(root->right, expectNumber, nums, retnums);
	}
	vector<vector<int>> FindPath(TreeNode* root, int expectNumber) {
		vector<vector<int>> retnums;
		vector<int> nums;
		_FindPath(root, expectNumber, nums, retnums);
		return retnums;
	}
};
int main()
{
	TreeNode* root = new TreeNode(10);
	TreeNode* node1 = new TreeNode(5);
	TreeNode* node2 = new TreeNode(12);
	TreeNode* node3 = new TreeNode(4);
	TreeNode* node4 = new TreeNode(7);
	root->left = node1;
	root->right = node2;
	node1->left = node3;
	node1->right = node4;
	vector<vector<int>> retnums = Solution().FindPath(root, 22);
	return 0;
}